home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 July / macformat-039.iso / Shareware City / Graphics / Clut Converter / Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-29  |  1.9 KB  |  82 lines  |  [TEXT/CWIE]

  1. /* Convert photoshop 2.5.x and 3.x clut files to clut resource files
  2.  
  3. Actual conversion routine "PShopPal v1.0" by Reevan McKay.
  4. Minimal user interface added by Mark Elliott, 28 Jan 1996.
  5. Makes no system checks. Currently only works for 256 colour cluts.
  6. Could be modified to allow combination of colours from more than
  7. one clut (put up a dialog to get the values of position and
  8. colorCount). I will probably do this next.
  9.  
  10. I make no warranty about the suitability of this program for any
  11. purpose. It shouldn't be able to do any damage since it hardly
  12. does anything at all, but then again it might. If something
  13. goes wrong, tell me and I will fix the program, but I won't
  14. fix your hard disk!!!!!
  15.  
  16.  
  17.  
  18. */
  19.  
  20.  
  21.  
  22. #include <pictutils.h>
  23. #include <memory.h>
  24.  
  25. extern    OSErr        LoadPalette (FSSpec theFSpec, CTabHandle    theCtab,
  26.                                 unsigned char position, unsigned char colorCount);
  27.  
  28.  
  29. void    main    (void)
  30. {
  31.     short                clutFile;
  32.     FSSpec                clutResFile;
  33.     OSErr                theError;
  34.     CTabHandle            theCtab;
  35.     SFTypeList            theTypes;
  36.     StandardFileReply    myReply, saveReply;
  37.     
  38.     
  39.     InitGraf( &qd.thePort );
  40.     InitFonts();
  41.     InitWindows();
  42.     FlushEvents( everyEvent, 0 );
  43.     InitCursor();
  44.     InitMenus();
  45.     TEInit();
  46.     InitDialogs( 0L );
  47.     
  48.     theCtab = GetCTable(8); // start with the system 8-bit clut
  49.     
  50.     theTypes[0] = '8BCT';    // photoshop clut file type
  51.     
  52.     StandardGetFile(nil, 1, theTypes, &myReply);
  53.             
  54.     if (myReply.sfGood)
  55.     {
  56.         theError =    LoadPalette (myReply.sfFile, theCtab, 0, 255);
  57.     
  58.         // create a resource file for the clut resource
  59.             
  60.         if (theError == 0L)
  61.         {
  62.             StandardPutFile("\pSave clut as...", "\pclut resource", &saveReply);
  63.             
  64.             if (saveReply.sfGood)
  65.             {
  66.                 FSpCreateResFile( &saveReply.sfFile, 'RSED', 'rsrc', smCurrentScript);
  67.                 FSpOpenResFile( &saveReply.sfFile, fsRdWrPerm );
  68.     
  69.                 /* get the file number */
  70.             
  71.                 clutFile = CurResFile();
  72.     
  73.             
  74.                 /* add the new resource to the file */
  75.             
  76.                 AddResource((Handle)theCtab, 'clut', 128, "\p");
  77.                 UpdateResFile(CurResFile());
  78.             }
  79.         }
  80.             
  81.     }
  82. }